<?php

namespace app\data\api;

use think\Collection;

/**
 * @package app\data\api
 */
interface ApiModel
{
    /**
     *
     * 新增一条数据
     *
     * @param array $data
     * @return int
     */
    public function add(array $data): int;

    /**
     *
     * 新增多条数据
     *
     * @param array $data
     * @return int
     */
    public function addAll(array $data): int;

    /**
     *
     * 修改一条数据
     *
     * @param array $where
     * @param array $data
     * @param false $lock
     * @return int|bool
     */
    public function edit(array $where, array $data, bool $lock = false): int|bool;

    /**
     *
     * 修改多条数据
     *
     * @param array $data
     * @return array
     */
    public function editAll(array $data): Collection;

    /**
     *
     * 删除一条数据
     *
     * @param array $where
     * @return int|bool
     */
    public function del(array $where): int|bool;

    /**
     *
     * 软删除一条数据
     *
     * @param array $where
     * @return int|bool
     */
    public function softDel(array $where = []): int|bool;

    /**
     *
     * 查询一条数据
     *
     * @param array $where
     * @param string $field
     * @return array
     */
    public function findOne(array $where = [], string $field = '*'): array;

    /**
     *
     * 查询多条数据
     *
     * @param array $where
     * @param string $field
     * @param string $order
     * @return array
     */
    public function findAll(array $where = [], string $field = '*',string $order = ''): array;

    /**
     *
     * 统计
     *
     * @param array $where
     * @return int
     */
    public function total(array $where): int;

    /**
     *
     * 分页
     *
     * @param int $page_index
     * @param int $page_size
     * @param array $where
     * @param string $field
     * @param string $order
     * @return array
     */
    public function pages(int $page_index = 1,int $page_size = 10,array $where = [],string $field = '*',string $order = ''): array;

    /**
     *
     * 快速分页
     *
     * @param int $max_id
     * @param int $page_size
     * @param array $where
     * @param string $field
     * @param string $order
     * @return array
     */
    public function paging(int $max_id = 1,int $page_size = 10,array $where = [],string $field = '*',string $order = ''): array;

    /**
     *
     * 聚合数据
     *
     * @param array $where
     * @param string $table
     * @param string $joinTable
     * @param string $on
     * @param string $field
     * @param string $order
     * @return array
     */
    public function joinData(array $where = [],string $table = '',string $joinTable = '',string $on = '',string $field = '*',string $order = ''): array;

    /**
     *
     * 聚合分页
     *
     * @param int $page_index
     * @param int $page_size
     * @param array $where
     * @param string $table
     * @param string $joinTable
     * @param string $on
     * @param string $field
     * @param string $order
     * @return array
     */
    public function joinPage(int $page_index = 1,int $page_size = 10,array $where = [],string $table = '',string $joinTable = '',string $on = '',string $field = '*',string $order = ''): array;

    /**
     *
     * 聚合分页（上一页下一页）
     *
     * @param int $page_size
     * @param array $where
     * @param string $table
     * @param string $joinTable
     * @param string $on
     * @param string $field
     * @param string $order
     * @return array
     */
    public function joinPaging(int $page_size = 10,array $where = [],string $table = '',string $joinTable = '',string $on = '',string $field = '*',string $order = ''): array;
    /**
     *
     * 字段加
     *
     * @param array $where
     * @param string $field
     * @param int $step
     * @return int
     */
    public function incr(array $where,string $field,int $step = 1): int;

    /**
     *
     * 字段减
     *
     * @param array $where
     * @param string $field
     * @param int $step
     * @return int
     */
    public function decr(array $where,string $field,int $step = 1): int;
}